/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package PropertyRental.war.servlets;

import PropertyRental.war.beans.Catalog;
import PropertyRental.war.beans.CatalogProperty;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Sébastien
 */
public class UpdatePropertyFormAction extends Action {
    public UpdatePropertyFormAction(String success, String fail) {
        super(success,fail);
    }

    @Override
    public String perform(HttpServletRequest req) {
        
        Long id = Long.parseLong(req.getParameter("id"));
        String type = req.getParameter("type");
        String adress = req.getParameter("adress");
        int numberBedroom = Integer.parseInt(req.getParameter("numberBedroom"));
        int numberBathroom = Integer.parseInt(req.getParameter("numberBathroom"));
        int numberOtherRoom = Integer.parseInt(req.getParameter("numberOtherRoom"));
        double rent = Double.parseDouble(req.getParameter("rent"));
        String location = req.getParameter("location");

        CatalogProperty results = new CatalogProperty(id,type, adress, numberBedroom, numberBathroom, numberOtherRoom, rent, location);

        req.setAttribute("property", results);

        return this.getSuccesspage();

    }

}
